Sub Main()
Dim matrix(,) As Integer = {
{1, 2, 3},
{2, 4, 2},
{3, 2, 1}
}
If IsPersymmetric(matrix) Then
Console.WriteLine("Матрица персимметрична.")
Else
Console.WriteLine("Матрица не персимметрична.")
End If
End Sub
Function IsPersymmetric(matrix(,) As Integer) As Boolean
Dim rows As Integer = matrix.GetLength(0)
Dim cols As Integer = matrix.GetLength(1)
If rows <> cols Then
Return False
End If
For i As Integer = 0 To rows - 1
For j As Integer = 0 To cols - 1
If matrix(i, j) <> matrix(rows - j - 1, rows - i - 1) Then
Return False
End If
Next
Next
Return True
End Function